package org.joy.db2;

import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

public class IndexDB extends DB {

    public HashMap<Integer, List<DocHit>> map() throws IOException {
	HashMap<Integer, List<DocHit>> map = new HashMap<Integer, List<DocHit>>();
	DBCursor c = openCursor();
	while (c.next()) {
	    IndexEntry e = new IndexEntry();
	    e.read(c.getKey(), c.getVal());
	    if (map.get(e.getTermID()) == null) {
		map.put(e.getTermID(), new LinkedList<DocHit>());
	    }
	    map.get(e.getTermID()).add(new DocHit(e));
	    //System.out.println(e.getTermID() + "\t" + e.getURLID());
	}
	c.close();
	return map;
    }
}
